package Controller.Action;

import java.io.File;
import java.io.IOException;

import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

import model.Player;

public class Mp3LengthController {
    public void actionPerformed(File mp3, JLabel toChange) {
        new mp3Thread(mp3, toChange).start();
    }
    
    class mp3Thread extends Thread{
        private File file;
        private JLabel label;
        public mp3Thread(File file, JLabel label){
            this.file = file;
            this.label = label;
        }
        public void run() {
            try {
                label.setText(Player.getTrackLength(file));
            } catch (UnsupportedAudioFileException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}
